package com.mxf.code.cases.order;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author : [mxf]
 * @version : [v1.0]
 * @className : RabbitmqServiceImpl
 * @description : [描述说明该类的功能]
 * @createTime : [2022/9/21 17:06]
 * @updateUser : [mxf]
 * @updateTime : [2022/9/21 17:06]
 * @updateRemark : [描述说明本次修改内容]
 */
@Service(value = "si2")
public class RabbitmqServiceImpl2 {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private RabbitMqConfirmCallback rabbitMqConfirmCallback;

    @Autowired
    private RabbitMqReturnCallback rabbitMqReturnCallback;

    /**
     * 发送消息到mq(单个)
     *
     * @param exchange   交换机的名称
     * @param routingKey 路由key值
     * @param messages   消息的附件消息
     */
    public void sendMessage(String exchange, String routingKey, String messages, CorrelationData correlationData) {
        /*rabbitTemplate.setConfirmCallback(null);
        rabbitTemplate.setReturnCallback(null);
        rabbitTemplate.setMandatory(false);*/
        rabbitTemplate.convertAndSend(exchange, routingKey, messages, correlationData);
    }
}
